<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Fetch通信(兼容性不好)</title>
</head>
<body>
<script>
    fetch('/books/123', {
        method: 'PUT',
        body: JSON.stringify({
            name: 'listi',
            age: 12
        }),
        headers: {
            'Content-Type': 'application/json',
        }
    }).then(data => {
        /* 返回的是promise对象这是fetch的api */
        return data.text();
    }).then(ret => {
        // 返回的是字符串如果需要对象则使用JSON.parse()转换为json对象
        console.log(ret);
    })
</script>
</body>
</html>